What is CSV?
CSV( Comma-Separated Value) is a file which stores tabular data including numbers and text in a plain text form. That is to say, a CSV file is a sequence of characters. No data in it has been interpreted instead. Any number of records contained in CSV file are separated by line breaks of some kind. Also there are fields in each record. They are separated by other character, comma, string or a literal TAB. So in common cases, all records own an sequence of fields that is exactly alike.
What is the function of CSV?
CSV, as a relatively simple file format, is widely supported by business, consumer and scientific applications. It is best used to represent sequences of records. Besides, a CSV file enables users to transfer information from a database program to a spreadsheet that uses a completely different format. However, CSV format, as its name indicate, using the comma to separate data fields, lacks of standardization. Anyhow, CSV is indispensable in people’s daily work, which requires people to convert documents of other formats to CSV. So I would like to share a simple method to convert excel to CSV with C#, VB.NET.In order to quickly finish Excel to CSV conversion with C#,VB.NET, I choose a .NET component Spire.XLS to help me. It works rather well and only needs three steps. So why not give it a try to freely install Spire.XLS in your system.
CSV( Comma-Separated Value) is a file which stores tabular data including numbers and text in a plain text form. That is to say, a CSV file is a sequence of characters. No data in it has been interpreted instead. Any number of records contained in CSV file are separated by line breaks of some kind. Also there are fields in each record. They are separated by other character, comma, string or a literal TAB. So in common cases, all records own an sequence of fields that is exactly alike.
What is the function of CSV?
CSV, as a relatively simple file format, is widely supported by business, consumer and scientific applications. It is best used to represent sequences of records. Besides, a CSV file enables users to transfer information from a database program to a spreadsheet that uses a completely different format. However, CSV format, as its name indicate, using the comma to separate data fields, lacks of standardization. Anyhow, CSV is indispensable in people’s daily work, which requires people to convert documents of other formats to CSV. So I would like to share a simple method to convert excel to CSV with C#, VB.NET.In order to quickly finish Excel to CSV conversion with C#,VB.NET, I choose a .NET component Spire.XLS to help me. It works rather well and only needs three steps. So why not give it a try to freely install Spire.XLS in your system.
How to Convert Excel to CSV with C#,VB.NET?
Using Spire.XLS, you need not use Microsoft Office Excel installed in your computer. It supports C#, VB.NET, ASP. NET, ASP.NET MVC and Silverlight. Please see the below simple procedure.
Procedure
Step1. Create a new workbook.
Step2. Load an excel file from system, and transfer the information into workbook.
Step3. Save workbook as any CSV file format and launch the file.
Main Code:
Using Spire.XLS, you need not use Microsoft Office Excel installed in your computer. It supports C#, VB.NET, ASP. NET, ASP.NET MVC and Silverlight. Please see the below simple procedure.
Procedure
Step1. Create a new workbook.
Step2. Load an excel file from system, and transfer the information into workbook.
Step3. Save workbook as any CSV file format and launch the file.
Main Code:
C# Code Convert Excel to CSV:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Xls;
namespace xls2csv
{
class Program
{
static void Main(string[] args)
{
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"C:\e-iceblue\employee.xls");
Worksheet sheet = workbook.Worksheets[0];
sheet.SaveToFile("sample.csv", ",", Encoding.UTF8);
System.Diagnostics.Process.Start("sample.csv");
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Spire.Xls;
namespace xls2csv
{
class Program
{
static void Main(string[] args)
{
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"C:\e-iceblue\employee.xls");
Worksheet sheet = workbook.Worksheets[0];
sheet.SaveToFile("sample.csv", ",", Encoding.UTF8);
System.Diagnostics.Process.Start("sample.csv");
}
}
}
VB.NET Code Convert Excel to CSV:
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Spire.Xls
Namespace xls2csv
Class Program
Private Shared Sub Main(args As String())
Dim workbook As New Workbook()
workbook.LoadFromFile("C:\e-iceblue\employee.xls")
Dim sheet As Worksheet = workbook.Worksheets(0)
sheet.SaveToFile("sample.csv", ",", Encoding.UTF8)
System.Diagnostics.Process.Start("sample.csv")
End Sub
End Class
End Namespace
Preview
Imports System.Collections.Generic
Imports System.Linq
Imports System.Text
Imports Spire.Xls
Namespace xls2csv
Class Program
Private Shared Sub Main(args As String())
Dim workbook As New Workbook()
workbook.LoadFromFile("C:\e-iceblue\employee.xls")
Dim sheet As Worksheet = workbook.Worksheets(0)
sheet.SaveToFile("sample.csv", ",", Encoding.UTF8)
System.Diagnostics.Process.Start("sample.csv")
End Sub
End Class
End Namespace
Preview
Besides convert Excel to CSV, Spire.XLS also allows users to convert Excel to other different formats, such as convert Excel to PDF, HTML, XML, Image and so on. You can consult more by the below link.
More Excel Conversion
More Excel Conversion